package maurice.game;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.*;

import wiiusej.WiiUseApiManager;

public class DanseAvecMauriceGame extends JFrame implements WindowListener, KeyListener{
	private DanseAvecMauricePanel panel;
	
	public DanseAvecMauriceGame(String music){
		panel = new DanseAvecMauricePanel(music);
    	this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    	this.setVisible(true);
    	this.getContentPane().add(panel);
    	this.addWindowListener(this);
    	this.addKeyListener(this);
	}

	@Override
	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowClosed(WindowEvent arg0) {
		// TODO Auto-generated method stub
	}

	@Override
	public void windowClosing(WindowEvent arg0) {
		panel.disposeRessources();
		this.dispose();	
	}

	@Override
	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
	public void keyPressed(KeyEvent e) {

    	// escape = sortir
    	if (e.getKeyCode()==KeyEvent.VK_ESCAPE){
    		panel.disposeRessources();
    		dispose();
    	}
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
